//
//  WelcomeViewController.m
//  BluetoothBalloonHangingBasket
//
//  Created by FENGYL on 2016/12/7.
//  Copyright © 2016年 FENGYL. All rights reserved.
//

#import "WelcomeViewController.h"

static NSString * scrollViewIndex = @"ScrollViewIndex";
static NSString * welcomeImage = @"WelcomeImage";

@interface WelcomeViewController ()

@property (weak, nonatomic) IBOutlet UIButton *editButton;
@property (weak, nonatomic) IBOutlet UIButton *scanDeviceButton;

@property (assign , nonatomic) int index;

@end

@implementation WelcomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpUI];
    
}

-(void)viewWillAppear:(BOOL)animated{
    
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    
}

-(void)viewWillDisappear:(BOOL)animated{
    
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    
}

-(void)setUpUI{
    
    //获取document路径
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    
    //拼接路径
    NSString *filePath = [path stringByAppendingPathComponent:welcomeImage];
    
    UIImage * image = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
    
    if (!image) {
        
        image = [UIImage imageNamed:@"wp_01"];
        
    }
    
    self.view.layer.contents = (id)image.CGImage;
    
    self.editButton.layer.cornerRadius = 10;
    
    self.scanDeviceButton.layer.cornerRadius = 7;
    
    self.index = 0;
    
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
//    self.index++;
//    
//    NSLog(@"%d",self.index);
//    
//    if (self.index >= 20) {
//        
//        NSData * data = self.view.layer.contents;
//        
//        self.view.layer.contents = (id)[UIImage imageNamed:@"jj"].CGImage;
//        
//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//            
//            self.view.layer.contents = data;
//            
//        });
//        
//    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
